﻿/***********************************************************************************************
 * 
 * ProjectName: WMSSoft.Lib.Interfaces
 * 
 * Description: Provide the Interface to Start an Application
 * 
 * Created:     26.08.2015
 * 
 * Author:      matthias wagler - matthias@WMSSoft.de
 * 
 * Copyright:   Copyright 2015 by WMSSoft.de
 * 
 * License:     GPLv3
 * 
 * History:     26.08.2015 - matthias wagler matthias@WMSSoft.de   -   Created
 * 
 **********************************************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WMSSoft.Lib.Interfaces;
using WMSSoft.Lib.WinKStart;

namespace WMSSoft.WinKStart.Functions
{
    public class ApplicationStarter : iWinKStartFunctions
    {
        /// <summary>
        /// Interface Member to Initialise the Function
        /// </summary>
        public void Init()
        {

        }

        /// <summary>
        /// Run the Code for this WinKStart Function
        /// </summary>
        /// <param name="DataSource">DataSource to work with Data from</param>
        /// <param name="Filter">Path to specify the Sub - Folder in DataSource</param>
        /// <param name="Data">Data from GUI to work with</param>
        /// <returns></returns>
        public bool Run(Dictionary<string, object> Data)
        {
            try
            {
                if (Data != null && Data.ContainsKey("LinkFilename") == true && Data.ContainsKey("Arguments") == true)
                {
                    WMSSoft.Lib.Shell.ShellAPI.ShellExecute(0, "open", (String)Data["LinkFilename"], (String)Data["Arguments"], "", 5);
                    return true;
                }
                return false;
            }
            catch (Exception Ex)
            {
                WMSSoft.Lib.Basic.CMessagelogging.AppendMessage("Can't run Function 'ApplicationStarter'!", Ex, Lib.Basic.EMessageTypes.Error);
                return false;
            }
        }

        /// <summary>
        /// 
        /// </summary>
        public void Destroy()
        {

        }
    }
}
